package aero.cloudbase.awesomecombobox;

import java.util.Arrays;

import aero.cloudbase.awesomecombobox.AwesomeComboBox.SelectedItemClickEvent;
import aero.cloudbase.awesomecombobox.AwesomeComboBox.SelectedItemClickListener;

import com.vaadin.Application;
import com.vaadin.ui.ComboBox;
import com.vaadin.ui.Label;
import com.vaadin.ui.Window;

/**
 * The Application's "main" class
 */
@SuppressWarnings("serial")
public class WidgetTestApplication extends Application
{
    private Window window;
    private Label result = new Label("");

    @Override
    public void init()
    {
        window = new Window("Widget Test");
        setMainWindow(window);
        ComboBox cb = new ComboBox("Regular combobox", Arrays.asList("Test1", "Test2", "Test3", "Test4"));
        window.addComponent(cb);
        final AwesomeComboBox acb = new AwesomeComboBox("Awesome combobox", Arrays.asList("Test1", "Test2", "Test3",
                "Test4"));
        acb.setNewItemsAllowed(true);
        acb.setImmediate(true);
        acb.addListener(new SelectedItemClickListener() {
            @Override
            public void buttonClick(SelectedItemClickEvent event) {
                result.setValue(acb.getValue());
            }
        });
        acb.setValue("Test2");
        window.addComponent(acb);
        window.addComponent(result);
    }
    
}
